package com.bluegalaxy.sitescore.service.impl;

import com.bluegalaxy.sitescore.entity.*;
import com.bluegalaxy.sitescore.mapper.TbSurfaceWaterDrinkingWaterMapper;
import com.bluegalaxy.sitescore.mapper.TbSurfaceWaterEnvironmentMapper;
import com.bluegalaxy.sitescore.mapper.TbSurfaceWaterHumanFoodChainMapper;
import com.bluegalaxy.sitescore.mapper.TbSurfaceWaterOverLandMapper;
import com.bluegalaxy.sitescore.mapper.TbSurfaceWaterOverLandSMapper;
import com.bluegalaxy.sitescore.service.SurfaceWaterService;
import com.bluegalaxy.sitescore.service.support.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public  class SurfaceWaterServiceImpl extends BaseServiceImpl<TbSurfaceWaterOverLandMapper,TbSurfaceWaterOverLand> implements SurfaceWaterService {

    @Autowired
    private TbSurfaceWaterOverLandMapper tbSurfaceWaterOverLandMapper;
    @Autowired
    private TbSurfaceWaterOverLandSMapper tbSurfaceWaterOverLandSMapper;
    @Autowired
    private TbSurfaceWaterDrinkingWaterMapper tbSurfaceWaterDrinkingWaterMapper;
    @Autowired
    private TbSurfaceWaterEnvironmentMapper tbSurfaceWaterEnvironmentMapper;
    @Autowired
    private TbSurfaceWaterHumanFoodChainMapper tbSurfaceWaterHumanFoodChainMapper;

    @Override
    public List<TbScore> getSWOverLandList(int sourceId) {
       // int sourceId =1;
        List<TbScore> tbSurfaceWaterOverLandList = new ArrayList<>();
        TbSurfaceWaterOverLand tbSurfaceWaterOverLand = new TbSurfaceWaterOverLand();
        tbSurfaceWaterOverLand.setSource_id(sourceId);
        tbSurfaceWaterOverLand.setIs_delete(0);
        if(tbSurfaceWaterOverLandMapper.selectCount(tbSurfaceWaterOverLand)==0){
            return tbSurfaceWaterOverLandList;
        }else{

        }
        tbSurfaceWaterOverLandList = tbSurfaceWaterOverLandMapper.tbSurfaceWaterOverLandListBySourceId(sourceId);
        tbSurfaceWaterOverLandList.get(0).setUsed(true);
        return tbSurfaceWaterOverLandList;
    }

    @Override
    public boolean insertSWOverLand(SurfaceWaterOL surfaceWaterOL, int sourceId) {


        return false;
    }

    @Override
    public boolean delScore(int id, int sourceId) {
        if (tbSurfaceWaterOverLandMapper.delSurfaceWaterOL(id,sourceId)){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public BigDecimal caculateScore(SurfaceWaterOL surfaceWaterOL,int sourceId) {
        Date date = new Date();
        BigDecimal release = BigDecimal.valueOf(surfaceWaterOL.getContainment())
                .multiply(BigDecimal.valueOf(surfaceWaterOL.getRunoff()
                        +surfaceWaterOL.getDis_surface_water())).add(
                                BigDecimal.valueOf(surfaceWaterOL.getPot_containment()
                                        *surfaceWaterOL.getPot_flood_frequency()));
        if (release.compareTo(BigDecimal.valueOf(500))==1){
            release = BigDecimal.valueOf(500);
        }
        if (surfaceWaterOL.getObs_release()==550){
            release = BigDecimal.valueOf(550);
        }
        BigDecimal dwTarget = BigDecimal.valueOf(surfaceWaterOL.getPop_concent1()*10).add(
                BigDecimal.valueOf(surfaceWaterOL.getPop_concent2()).add(
                        BigDecimal.valueOf(surfaceWaterOL.getPotential_contanmination()*0.1))).add(
                                BigDecimal.valueOf(surfaceWaterOL.getNearest_intake())).add(
                                        BigDecimal.valueOf(surfaceWaterOL.getResource()));

        BigDecimal dwUScore = release.multiply(dwTarget).multiply(
                BigDecimal.valueOf(surfaceWaterOL.getWaste_characteristics())).divide(
                        BigDecimal.valueOf(82500),2, RoundingMode.DOWN);

        BigDecimal dwScore = null;
        if (dwUScore.compareTo(BigDecimal.valueOf(100))==1){
            dwScore = BigDecimal.valueOf(100);
        }else {
            dwScore = dwUScore;
        }

        BigDecimal hfTarget = BigDecimal.valueOf(surfaceWaterOL.getPop_concent12().floatValue()*10).add(
                BigDecimal.valueOf(surfaceWaterOL.getPop_concent22().floatValue()).add(
                        BigDecimal.valueOf(surfaceWaterOL.getPot_HFC_concent().floatValue()*0.1))).add(
                BigDecimal.valueOf(surfaceWaterOL.getFood_chain_individual()));

        BigDecimal hfUScore = release.multiply(hfTarget).multiply(
                BigDecimal.valueOf(surfaceWaterOL.getWaste_characteristics2())).divide(
                BigDecimal.valueOf(82500),2, RoundingMode.DOWN);

        BigDecimal hfScore = null;
        if (hfUScore.compareTo(BigDecimal.valueOf(100))==1){
            hfScore = BigDecimal.valueOf(100);
        }else {
            hfScore = hfUScore;
        }
        BigDecimal eTarget = BigDecimal.valueOf(surfaceWaterOL.getPop_concent13()*10).add(
                BigDecimal.valueOf(surfaceWaterOL.getPop_concent23()).add(
                        BigDecimal.valueOf(surfaceWaterOL.getPotential_contanmination3()*0.1)));

        BigDecimal eUScore = release.multiply(eTarget).multiply(
                BigDecimal.valueOf(surfaceWaterOL.getWaste_cha())).divide(
                BigDecimal.valueOf(82500),2, RoundingMode.DOWN);

        BigDecimal eScore = null;
        if (eUScore.compareTo(BigDecimal.valueOf(100))==1){
            eScore = BigDecimal.valueOf(100);
        }else {
            eScore = eUScore;
        }

        BigDecimal score = dwScore.add(hfScore).add(eScore);
        if (score.compareTo(BigDecimal.valueOf(100))==1){
            score = BigDecimal.valueOf(100);
        }
        TbSurfaceWaterOverLand tbSurfaceWaterOverLand = new TbSurfaceWaterOverLand();
        tbSurfaceWaterOverLand.setId(surfaceWaterOL.getId());
        tbSurfaceWaterOverLand.setSource_id(sourceId);
        tbSurfaceWaterOverLand.setWaterShed_name(surfaceWaterOL.getWaterShed_name());
        tbSurfaceWaterOverLand.setObs_release(surfaceWaterOL.getObs_release());
        tbSurfaceWaterOverLand.setContainment(surfaceWaterOL.getContainment());
        tbSurfaceWaterOverLand.setRunoff(surfaceWaterOL.getRunoff());
        tbSurfaceWaterOverLand.setDis_surface_water(surfaceWaterOL.getDis_surface_water());
        tbSurfaceWaterOverLand.setOverland_flow(surfaceWaterOL.getOverland_flow());
        tbSurfaceWaterOverLand.setPot_containment(surfaceWaterOL.getPot_containment());
        tbSurfaceWaterOverLand.setPot_flood_frequency(surfaceWaterOL.getPot_flood_frequency());
        tbSurfaceWaterOverLand.setPot_pot_to_rele_flo(surfaceWaterOL.getPot_pot_to_rele_flo());
        tbSurfaceWaterOverLand.setPro_to_release(surfaceWaterOL.getPro_to_release());
        tbSurfaceWaterOverLand.setLikeihood_release(surfaceWaterOL.getLikeihood_release());
        tbSurfaceWaterOverLand.setIs_delete(0);
        System.out.println(tbSurfaceWaterOverLand.getId());
        if (tbSurfaceWaterOverLand.getId()==0) {
            tbSurfaceWaterOverLandMapper.insertGetId(tbSurfaceWaterOverLand);
        }
        else {
            tbSurfaceWaterOverLandMapper.updateSurfaceWaterOL(tbSurfaceWaterOverLand);
        }
        int id = tbSurfaceWaterOverLand.getId();


        TbSurfaceWaterHumanFoodChain tbSurfaceWaterHumanFoodChain = new TbSurfaceWaterHumanFoodChain();
        tbSurfaceWaterHumanFoodChain.setSource_id(sourceId);
        tbSurfaceWaterHumanFoodChain.setSurface_water_id(id);
        //不知是啥
        tbSurfaceWaterHumanFoodChain.setOver_load_id(1);
        tbSurfaceWaterHumanFoodChain.setWater_category(1);
        tbSurfaceWaterHumanFoodChain.setBody_type(1);
        //此处为float
        tbSurfaceWaterHumanFoodChain.setBioa_val(surfaceWaterOL.getBioa_val().floatValue());

        tbSurfaceWaterHumanFoodChain.setHaz_waster_quantity(surfaceWaterOL.getHaza_quantity2());
        tbSurfaceWaterHumanFoodChain.setWaste_cha(surfaceWaterOL.getWaste_characteristics2());
        tbSurfaceWaterHumanFoodChain.setFood_chain_individual(surfaceWaterOL.getFood_chain_individual());
        //此几处应为float
        tbSurfaceWaterHumanFoodChain.setPop_concent1(surfaceWaterOL.getPop_concent12().floatValue());
        tbSurfaceWaterHumanFoodChain.setPop_concent2(surfaceWaterOL.getPop_concent22().floatValue());
        tbSurfaceWaterHumanFoodChain.setPot_HFC_concent(surfaceWaterOL.getPot_HFC_concent().floatValue());
        tbSurfaceWaterHumanFoodChain.setPopulation(surfaceWaterOL.getPopulation2().floatValue());
        tbSurfaceWaterHumanFoodChain.setTargets(surfaceWaterOL.getTarget2().floatValue());

        tbSurfaceWaterHumanFoodChain.setHuman_food_chain_score(surfaceWaterOL.getHuman_food_chain_score().floatValue());
        tbSurfaceWaterHumanFoodChain.setUncapped_score(surfaceWaterOL.getUncapped_score2().floatValue());
        tbSurfaceWaterHumanFoodChain.setUpdate_time(date);
        tbSurfaceWaterHumanFoodChain.setIs_delete(0);
        if(surfaceWaterOL.getId()==0) {
            tbSurfaceWaterHumanFoodChain.setCreate_time(date);
            tbSurfaceWaterHumanFoodChainMapper.insert(tbSurfaceWaterHumanFoodChain);
        }else {
            tbSurfaceWaterHumanFoodChainMapper.updateBySid(tbSurfaceWaterHumanFoodChain);
        }

        TbSurfaceWaterDrinkingWater tbSurfaceWaterDrinkingWater = new TbSurfaceWaterDrinkingWater();
        tbSurfaceWaterDrinkingWater.setSource_id(sourceId);
        tbSurfaceWaterDrinkingWater.setSurface_water_id(id);
        //中间空了两个
        tbSurfaceWaterDrinkingWater.setHaza_quantity(surfaceWaterOL.getHaza_quantity());
        tbSurfaceWaterDrinkingWater.setWaste_characteristics(surfaceWaterOL.getWaste_characteristics());
        tbSurfaceWaterDrinkingWater.setNearest_intake(surfaceWaterOL.getNearest_intake());
        tbSurfaceWaterDrinkingWater.setPop_concent1(surfaceWaterOL.getPop_concent1());
        tbSurfaceWaterDrinkingWater.setPop_concent2(surfaceWaterOL.getPop_concent2());
        tbSurfaceWaterDrinkingWater.setPotential_contanmination(surfaceWaterOL.getPotential_contanmination());
        //此处应为float
        tbSurfaceWaterDrinkingWater.setPopulation(surfaceWaterOL.getPopulation().floatValue());

        tbSurfaceWaterDrinkingWater.setResource(surfaceWaterOL.getResource());
        //此处应为float
        tbSurfaceWaterDrinkingWater.setTarget(surfaceWaterOL.getTarget().floatValue());

        tbSurfaceWaterDrinkingWater.setDrinking_water_score(surfaceWaterOL.getDrinking_water_score().floatValue());
        tbSurfaceWaterDrinkingWater.setUncapped_score(surfaceWaterOL.getUncapped_score3().floatValue());
        tbSurfaceWaterDrinkingWater.setUpdate_time(date);
        tbSurfaceWaterDrinkingWater.setIs_delete(0);
        if(surfaceWaterOL.getId()==0) {
            tbSurfaceWaterDrinkingWater.setCreate_time(date);
            tbSurfaceWaterDrinkingWaterMapper.insert(tbSurfaceWaterDrinkingWater);
        }else {
            tbSurfaceWaterDrinkingWaterMapper.updateBySid(tbSurfaceWaterDrinkingWater);
        }

        TbSurfaceWaterEnvironment tbSurfaceWaterEnvironment = new TbSurfaceWaterEnvironment();
        tbSurfaceWaterEnvironment.setSource_id(sourceId);
        tbSurfaceWaterEnvironment.setSurface_water_id(id);
        //中间空了三个
        //不知是啥
        tbSurfaceWaterEnvironment.setWater_category(1);
        tbSurfaceWaterEnvironment.setUsing_substance(1);
        tbSurfaceWaterEnvironment.setEcosystem_bap_value(surfaceWaterOL.getEcosystem_bap_value().floatValue());

        tbSurfaceWaterEnvironment.setHaz_waster_quantity(surfaceWaterOL.getHaz_waster_quantity());
        tbSurfaceWaterEnvironment.setWaste_cha(surfaceWaterOL.getWaste_cha());
        //重复字段
        tbSurfaceWaterEnvironment.setSensitive_environment(surfaceWaterOL.getPop_sensitive_environments().intValue());

        tbSurfaceWaterEnvironment.setPop_concent1(surfaceWaterOL.getPop_concent13());
        tbSurfaceWaterEnvironment.setPop_concent2(surfaceWaterOL.getPop_concent23());
        tbSurfaceWaterEnvironment.setPotential_contanmination(surfaceWaterOL.getPotential_contanmination3());
        //此处应为float
        tbSurfaceWaterEnvironment.setPop_sensitive_environments(surfaceWaterOL.getPop_sensitive_environments().floatValue());
        //此处应为target,且为float值
        tbSurfaceWaterEnvironment.setResources(surfaceWaterOL.getTarget3().floatValue());

        tbSurfaceWaterEnvironment.setEnvironment_score(eScore.floatValue());
        tbSurfaceWaterEnvironment.setUncapped_score(eUScore.floatValue());
        tbSurfaceWaterEnvironment.setUpdate_time(date);
        tbSurfaceWaterEnvironment.setIs_delete(0);
        if (surfaceWaterOL.getId()==0) {
            tbSurfaceWaterEnvironment.setCreate_time(date);
            tbSurfaceWaterEnvironmentMapper.insert(tbSurfaceWaterEnvironment);
        }else {
            tbSurfaceWaterEnvironmentMapper.updateBySid(tbSurfaceWaterEnvironment);
        }



        return score;
    }

    @Override
    public BigDecimal caculateScoreGroud(SurfaceWaterGW surfaceWaterOL,int sourceId) {
        Date date = new Date();
        BigDecimal release = BigDecimal.valueOf(surfaceWaterOL.getContainment())
                .multiply(BigDecimal.valueOf(surfaceWaterOL.getNet_precip()).add(
                        BigDecimal.valueOf(surfaceWaterOL.getDepth_to_auuifer()).add(
                                BigDecimal.valueOf(surfaceWaterOL.getTravel_time())
                        )
                ));

        if (release.compareTo(BigDecimal.valueOf(500))==1){
            release = BigDecimal.valueOf(500);
        }
        if (surfaceWaterOL.getObserved_release()==550){
            release = BigDecimal.valueOf(550);
        }
        BigDecimal dwTarget = BigDecimal.valueOf(surfaceWaterOL.getPop_concent1()*10).add(
                BigDecimal.valueOf(surfaceWaterOL.getPop_concent2()).add(
                        BigDecimal.valueOf(surfaceWaterOL.getPotential_contanmination()*0.1))).add(
                BigDecimal.valueOf(surfaceWaterOL.getNearest_intake())).add(
                BigDecimal.valueOf(surfaceWaterOL.getResource()));
        BigDecimal dwUScore = release.multiply(dwTarget).multiply(
                BigDecimal.valueOf(surfaceWaterOL.getWaste_characteristics())).divide(
                BigDecimal.valueOf(82500),2, RoundingMode.DOWN);
        BigDecimal dwScore = null;
        if (dwUScore.compareTo(BigDecimal.valueOf(100))==1){
            dwScore = BigDecimal.valueOf(100);
        }else {
            dwScore = dwUScore;
        }
        BigDecimal hfTarget = BigDecimal.valueOf(surfaceWaterOL.getPop_concent12()*10).add(
                BigDecimal.valueOf(surfaceWaterOL.getPop_concent22()).add(
                        BigDecimal.valueOf(surfaceWaterOL.getPot_HFC_concent()*0.1))).add(
                BigDecimal.valueOf(surfaceWaterOL.getFood_chain_individual()));

        BigDecimal hfUScore = release.multiply(hfTarget).multiply(
                BigDecimal.valueOf(surfaceWaterOL.getWaste_characteristics2())).divide(
                BigDecimal.valueOf(82500),2, RoundingMode.DOWN);

        BigDecimal hfScore = null;
        if (hfUScore.compareTo(BigDecimal.valueOf(100))==1){
            hfScore = BigDecimal.valueOf(100);
        }else {
            hfScore = hfUScore;
        }
        BigDecimal eTarget = BigDecimal.valueOf(surfaceWaterOL.getPop_concent13()*10).add(
                BigDecimal.valueOf(surfaceWaterOL.getPop_concent23()).add(
                        BigDecimal.valueOf(surfaceWaterOL.getPotential_contanmination3()*0.1)));

        BigDecimal eUScore = release.multiply(eTarget).multiply(
                BigDecimal.valueOf(surfaceWaterOL.getWaste_cha())).divide(
                BigDecimal.valueOf(82500),2, RoundingMode.DOWN);

        BigDecimal eScore = null;
        if (eUScore.compareTo(BigDecimal.valueOf(100))==1){
            eScore = BigDecimal.valueOf(100);
        }else {
            eScore = eUScore;
        }
        BigDecimal score = dwScore.add(hfScore).add(eScore);
        if (score.compareTo(BigDecimal.valueOf(100))==1){
            score = BigDecimal.valueOf(100);
        }
        TbGroundWaterToSw tbGroundWaterToSw = new TbGroundWaterToSw();
        tbGroundWaterToSw.setSorce_id(sourceId);
        tbGroundWaterToSw.setWatershed_name(surfaceWaterOL.getWaterShed_name());
        tbGroundWaterToSw.setContainment(surfaceWaterOL.getContainment());
        tbGroundWaterToSw.setCreate_time(date);
        tbGroundWaterToSw.setDepth_to_auuifer(surfaceWaterOL.getDepth_to_auuifer());
        tbGroundWaterToSw.setLikeihood_release(surfaceWaterOL.getLikeihood_release());
        tbGroundWaterToSw.setIs_delete(0);
        tbGroundWaterToSw.setNet_precip(surfaceWaterOL.getNet_precip());
        tbGroundWaterToSw.setObserved_release(surfaceWaterOL.getObserved_release());
        tbGroundWaterToSw.setPotential_to_release(surfaceWaterOL.getPotential_to_release());
        tbGroundWaterToSw.setTravel_time(surfaceWaterOL.getTravel_time());
        tbGroundWaterToSw.setUpdate_time(date);
        tbGroundWaterToSw.setWatershed_score(score.floatValue());
        //显示时应单独额外计算
        tbGroundWaterToSw.setMigration_score(score.floatValue());
        //TbSurfaceWaterOverLand tbSurfaceWaterOverLand = new TbSurfaceWaterOverLand();
        /*tbSurfaceWaterOverLand.setSource_id(sourceId);
        tbSurfaceWaterOverLand.setWaterShed_name(surfaceWaterOL.getWaterShed_name());
        tbSurfaceWaterOverLand.setObs_release(surfaceWaterOL.getObs_release());
        tbSurfaceWaterOverLand.setContainment(surfaceWaterOL.getContainment());
        tbSurfaceWaterOverLand.setRunoff(surfaceWaterOL.getRunoff());
        tbSurfaceWaterOverLand.setDis_surface_water(surfaceWaterOL.getDis_surface_water());
        tbSurfaceWaterOverLand.setOverland_flow(surfaceWaterOL.getOverland_flow());
        tbSurfaceWaterOverLand.setPot_containment(surfaceWaterOL.getPot_containment());
        tbSurfaceWaterOverLand.setPot_flood_frequency(surfaceWaterOL.getPot_flood_frequency());
        tbSurfaceWaterOverLand.setPot_pot_to_rele_flo(surfaceWaterOL.getPot_pot_to_rele_flo());
        tbSurfaceWaterOverLand.setPro_to_release(surfaceWaterOL.getPro_to_release());
        tbSurfaceWaterOverLand.setLikeihood_release(release.intValue());
        System.out.println(tbSurfaceWaterOverLand);
        tbSurfaceWaterOverLandMapper.insertGetId(tbSurfaceWaterOverLand);*/
    /*    int id = tbSurfaceWaterOverLand.getId();


        TbSurfaceWaterHumanFoodChain tbSurfaceWaterHumanFoodChain = new TbSurfaceWaterHumanFoodChain();
        tbSurfaceWaterHumanFoodChain.setSource_id(sourceId);
        tbSurfaceWaterHumanFoodChain.setSurface_water_id(id);
        //不知是啥
        tbSurfaceWaterHumanFoodChain.setOver_load_id(1);
        tbSurfaceWaterHumanFoodChain.setWater_category(1);
        tbSurfaceWaterHumanFoodChain.setBody_type(1);
        //此处为float
        tbSurfaceWaterHumanFoodChain.setBioa_val(surfaceWaterOL.getBioa_val().intValue());

        tbSurfaceWaterHumanFoodChain.setHaz_waster_quantity(surfaceWaterOL.getHaz_waster_quantity());
        tbSurfaceWaterHumanFoodChain.setWaste_cha(surfaceWaterOL.getWaste_cha());
        tbSurfaceWaterHumanFoodChain.setFood_chain_individual(surfaceWaterOL.getFood_chain_individual());
        //此几处应为float
        tbSurfaceWaterHumanFoodChain.setPop_concent1(surfaceWaterOL.getPop_concent12());
        tbSurfaceWaterHumanFoodChain.setPop_concent2(surfaceWaterOL.getPop_concent22());
        tbSurfaceWaterHumanFoodChain.setPot_HFC_concent(surfaceWaterOL.getPot_HFC_concent());
        tbSurfaceWaterHumanFoodChain.setPopulation(surfaceWaterOL.getPopulation().intValue());
        tbSurfaceWaterHumanFoodChain.setTargets(surfaceWaterOL.getTarget2().intValue());

        tbSurfaceWaterHumanFoodChain.setHuman_food_chain_score(hfScore.floatValue());
        tbSurfaceWaterHumanFoodChain.setUncapped_score(hfUScore.floatValue());
        tbSurfaceWaterHumanFoodChain.setCreate_time(date);
        tbSurfaceWaterHumanFoodChain.setUpdate_time(date);
        tbSurfaceWaterHumanFoodChain.setIs_delete(0);
        tbSurfaceWaterHumanFoodChainMapper.insert(tbSurfaceWaterHumanFoodChain);

        TbSurfaceWaterDrinkingWater tbSurfaceWaterDrinkingWater = new TbSurfaceWaterDrinkingWater();
        tbSurfaceWaterDrinkingWater.setSource_id(sourceId);
        tbSurfaceWaterDrinkingWater.setSurface_water_id(id);
        //中间空了两个
        tbSurfaceWaterDrinkingWater.setHaza_quantity(surfaceWaterOL.getHaza_quantity());
        tbSurfaceWaterDrinkingWater.setWaste_characteristics(surfaceWaterOL.getWaste_characteristics());
        tbSurfaceWaterDrinkingWater.setNearest_intake(surfaceWaterOL.getNearest_intake());
        tbSurfaceWaterDrinkingWater.setPop_concent1(surfaceWaterOL.getPop_concent1());
        tbSurfaceWaterDrinkingWater.setPop_concent2(surfaceWaterOL.getPop_concent2());
        tbSurfaceWaterDrinkingWater.setPotential_contanmination(surfaceWaterOL.getPotential_contanmination());
        //此处应为float
        tbSurfaceWaterDrinkingWater.setPopulation(surfaceWaterOL.getPopulation().intValue());

        tbSurfaceWaterDrinkingWater.setResource(surfaceWaterOL.getResource());
        //此处应为float
        tbSurfaceWaterDrinkingWater.setTarget(surfaceWaterOL.getTarget().intValue());

        tbSurfaceWaterDrinkingWater.setDrinking_water_score(dwScore.floatValue());
        tbSurfaceWaterDrinkingWater.setUncapped_score(dwUScore.floatValue());
        tbSurfaceWaterDrinkingWater.setCreate_time(date);
        tbSurfaceWaterDrinkingWater.setUpdate_time(date);
        tbSurfaceWaterDrinkingWater.setIs_delete(0);
        tbSurfaceWaterDrinkingWaterMapper.insert(tbSurfaceWaterDrinkingWater);

        TbSurfaceWaterEnvironment tbSurfaceWaterEnvironment = new TbSurfaceWaterEnvironment();
        tbSurfaceWaterEnvironment.setSource_id(sourceId);
        tbSurfaceWaterEnvironment.setSurface_water_id(id);
        //中间空了三个
        //不知是啥
        tbSurfaceWaterEnvironment.setWater_category(1);
        tbSurfaceWaterEnvironment.setUsing_substance(1);
        tbSurfaceWaterEnvironment.setEcosystem_bap_value(1);

        tbSurfaceWaterEnvironment.setHaz_waster_quantity(surfaceWaterOL.getHaz_waster_quantity());
        tbSurfaceWaterEnvironment.setWaste_cha(surfaceWaterOL.getWaste_cha());
        //重复字段
        tbSurfaceWaterEnvironment.setSensitive_environment(surfaceWaterOL.getPop_sensitive_environments().intValue());

        tbSurfaceWaterEnvironment.setPop_concent1(surfaceWaterOL.getPop_concent13());
        tbSurfaceWaterEnvironment.setPop_concent2(surfaceWaterOL.getPop_concent23());
        tbSurfaceWaterEnvironment.setPotential_contanmination(surfaceWaterOL.getPotential_contanmination3());
        //此处应为float
        tbSurfaceWaterEnvironment.setPop_sensitive_environments(surfaceWaterOL.getPop_sensitive_environments().intValue());
        //此处应为target,且为float值
        tbSurfaceWaterEnvironment.setResources(surfaceWaterOL.getTarget3().intValue());

        tbSurfaceWaterEnvironment.setEnvironment_score(eScore.floatValue());
        tbSurfaceWaterEnvironment.setUncapped_score(eUScore.floatValue());
        tbSurfaceWaterEnvironment.setCreate_time(date);
        tbSurfaceWaterEnvironment.setUpdate_time(date);
        tbSurfaceWaterEnvironment.setIs_delete(0);
        tbSurfaceWaterEnvironmentMapper.insert(tbSurfaceWaterEnvironment);*/



        return score;
    }

    @Override
    public boolean judgeScore(SurfaceWaterOL surfaceWaterOL) {
        if (surfaceWaterOL.getObs_release()!=550&&surfaceWaterOL.getObs_release()!=0){
            return  false;
        }else if (surfaceWaterOL.getContainment()!=0&&surfaceWaterOL.getContainment()!=3&&
                surfaceWaterOL.getContainment()!=5&&surfaceWaterOL.getContainment()!=7&&
                surfaceWaterOL.getContainment()!=9&&surfaceWaterOL.getContainment()!=10){
            return false;
        }else if (surfaceWaterOL.getRunoff()!=0&&surfaceWaterOL.getRunoff()!=1&&
                surfaceWaterOL.getRunoff()!=2&&surfaceWaterOL.getRunoff()!=3&&
                surfaceWaterOL.getRunoff()!=4&&surfaceWaterOL.getRunoff()!=7&&
                surfaceWaterOL.getRunoff()!=11&surfaceWaterOL.getRunoff()!=15&&
                surfaceWaterOL.getRunoff()!=17&&surfaceWaterOL.getRunoff()!=25){
            return false;
        }else if (surfaceWaterOL.getDis_surface_water()!=3&&surfaceWaterOL.getDis_surface_water()!=6&&
                surfaceWaterOL.getDis_surface_water()!=9&&surfaceWaterOL.getDis_surface_water()!=16&&
                surfaceWaterOL.getDis_surface_water()!=20&&surfaceWaterOL.getDis_surface_water()!=25){
            return false;
        }else if (surfaceWaterOL.getPot_containment()!=0&&surfaceWaterOL.getPot_containment()!=10){
            return false;
        }else if (surfaceWaterOL.getPot_flood_frequency()!=0&&surfaceWaterOL.getPot_flood_frequency()!=7&&
                surfaceWaterOL.getPot_flood_frequency()!=25&&surfaceWaterOL.getPot_flood_frequency()!=50){
            return false;
        }


        return true;
    }

    @Override
    public boolean judgeScoreGroud(SurfaceWaterGW surfaceWaterOL) {
        if (surfaceWaterOL.getObserved_release()!=550&&surfaceWaterOL.getObserved_release()!=0){
            return  false;
        }else if (surfaceWaterOL.getContainment()!=0&&surfaceWaterOL.getContainment()!=3&&
                surfaceWaterOL.getContainment()!=5&&surfaceWaterOL.getContainment()!=7&&
                surfaceWaterOL.getContainment()!=9&&surfaceWaterOL.getContainment()!=10){
            return false;
        }else if (surfaceWaterOL.getNet_precip()!=0&&surfaceWaterOL.getNet_precip()!=1&&
                surfaceWaterOL.getNet_precip()!=3&&surfaceWaterOL.getNet_precip()!=6&&
                surfaceWaterOL.getNet_precip()!=10){
            return false;
        }else if (surfaceWaterOL.getDepth_to_auuifer()!=1&&surfaceWaterOL.getDepth_to_auuifer()!=3&&
                surfaceWaterOL.getDepth_to_auuifer()!=5){
            return false;
        }else if (surfaceWaterOL.getTravel_time()!=1&&surfaceWaterOL.getTravel_time()!=5
                &&surfaceWaterOL.getTravel_time()!=15&&surfaceWaterOL.getTravel_time()!=25
                &&surfaceWaterOL.getTravel_time()!=35) {
            return false;
        }

        return true;
    }

    @Override
    public SurfaceWaterOL getSurfaceWaterById(int id) {
        return tbSurfaceWaterOverLandMapper.getTbSurfaceWaterOverLandById(id);
    }
}
